<?php

namespace app\admin\model;

use think\Db;

class AdminModel extends Model

{
//总条数
    public function count()
    {
        $list = Db::table('sys_admin')->select();
        $list_length = count($list);
        return $list_length;
    }

    public function list($page, $limit)
    {
        return Db::table('sys_admin')->page($page, $limit)->select();
    }

//分页查询
    public function add($data)
    {
        return Db::table('sys_admin')->insert($data);
    }

    public function delete($id)
    {
        return Db::table('sys_admin')->where('id=' . $id)->delete();
    }

    public function like($username)
    {
        return Db::table('sys_admin')->where('username', 'like', '%' . $username . '%')->select();
    }

    public function update($id, $data)
    {
        Db::table('sys_admin')->where('id=' . $id)->update($data);
    }

}